package com.lili.backtrack;

/**
 * @Auther: 李 力
 * @Date: 2024/8/21
 * @Description: 两数之和
 * @version: 1.0
 */
public class LeetCode167 {

    public int[] twoSum(int[] numbers, int target) {
        int i = 0;
        int j = numbers.length - 1;
        while (i < j) {
            int sum = numbers[i] + numbers[j];
            if (sum < target) {
                i++;
            } else if (sum > target) {
                j--;
            } else {
                break;
            }
        }
        return new int[]{i + 1, j + 1};
    }

}
